package control;

import java.io.IOException;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;

import blo.AddWordBLO;

public class Contribute extends BaseControl {
	public form.BaseForm procHome(ActionRequest request, ActionResponse response) throws PortletException, IOException {
		return null;
	}
	
	public form.Contribute procSubmit(ActionRequest request, ActionResponse response) throws PortletException, IOException {
		form.Contribute result = new form.Contribute();
		String txtWord = request.getParameter("txtWord");
		String txtmeaning = request.getParameter("txtTranslation");
		int slFrom = Integer.valueOf(request.getParameter("slFrom"));
		int slTo = Integer.valueOf(request.getParameter("slTo"));
		
		blo.AddWordBLO word = new AddWordBLO();
		boolean success = word.addSugestWord(txtWord, txtmeaning, slFrom, slTo);
		if(success) result.setSuccess(1);
		else result.setSuccess(0);
		return result;
	}

	public form.BaseForm procCancel(ActionRequest request, ActionResponse response) throws PortletException, IOException {
		return null;
	}
}
